﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using Mogre;

namespace WastedMechanics
{
    class Program
    {

        static void InitDescribedProfiles()
        {
            Engine.DescribedProfiles["Cormen"] = new DescribedProfile();
            Engine.DescribedProfiles["Cormen"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Cormen"].DisplayName = "Cormen";
            Engine.DescribedProfiles["Cormen"].Description = "Cormen - Wprowadzenie do algorytmów.\n\n" +
                "Książka ta to najlepszy w świecie podręcznik z dziedziny algorytmów i struktur danych." +
                "Omówiono w niej metody matematyczne stosowane do analizy algorytmów, sortowanie i statystyki pozycyjne, struktury " +
                "danych, podstawowe metody projektowania efektywnych algorytmów. Dużo miejsca poświęcono złożonym strukturom danych i " +
                "podstawowym algorytmom grafowym. Problemy przedstawione w książce to materiał dydaktyczny do wielu przedmiotów " +
                "informatycznych wykładanych w szkołach wyższych.";
            Engine.DescribedProfiles["Cormen"].DisplayNameOffset = new Vector3(0, 0.2f, 0);
            Engine.DescribedProfiles["Cormen"].IsPickable = true;
            Engine.DescribedProfiles["Cormen"].Mass = 20;
            Engine.DescribedProfiles["Cormen"].MeshName = "Cormen.mesh";

            Engine.DescribedProfiles["Concrete"] = new DescribedProfile();
            Engine.DescribedProfiles["Concrete"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Concrete"].DisplayName = "Konkretna";
            Engine.DescribedProfiles["Concrete"].Description = "Matematyka Konkretna.\n\n" +
                "Niezwykła książka o matematyce. Autorzy, wybitni matematycy informatyczni, dostrzegli " +
                "lukę na rynku wydawniczym - brak pozycji, w której byłyby zebrane treści matematyczne potrzebne informatykowi." +
                "Chodziło o wyłożenie metod rozwiązywania skomplikowanych problemów, wyliczania ogromnych sum i " +
                "dostrzegania subtelnych wzorców w otaczającym nas świecie. Umiejętności te potrzebne są przy " +
                "konstruowaniu i analizowaniu algorytmów komputerowych.";
            Engine.DescribedProfiles["Concrete"].DisplayNameOffset = new Vector3(0, 0.2f, 0);
            Engine.DescribedProfiles["Concrete"].IsPickable = true;
            Engine.DescribedProfiles["Concrete"].Mass = 20;
            Engine.DescribedProfiles["Concrete"].MeshName = "Concrete.mesh";

            Engine.DescribedProfiles["Colt"] = new DescribedProfile();
            Engine.DescribedProfiles["Colt"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Colt"].DisplayName = "Colt";
            Engine.DescribedProfiles["Colt"].Description = "Colt.\n\n" +
               "Konstrukcja ta była rewolucją na rynku broni palnej, gdyż będące w powszechnym użyciu pistolety oddawały " +
               "pojedynczy strzał i wymagały ponownego ładownia, co trwało około 20 sekund. Pierwszy egzemplarz, wykonany " +
               "w domowych warunkach, został zaprezentowany armii Stanów Zjednoczonych, lecz nie spotkał się z " +
               "zainteresowaniem z jej strony. Prawdopodobnie powodem takiego stanowiska był fakt, iż aby nabić " +
               "ponownie bębenek trzeba było rozebrać rewolwer, wyjąć go i dopiero ładować. Mimo to wyprodukowano parę " +
               "tysięcy egzemplarzy tego modelu.";
            Engine.DescribedProfiles["Colt"].DisplayNameOffset = new Vector3(0, 0.2f, 0);
            Engine.DescribedProfiles["Colt"].IsPickable = true;
            Engine.DescribedProfiles["Colt"].Mass = 20;
            Engine.DescribedProfiles["Colt"].MeshName = "Colt.mesh";

            Engine.DescribedProfiles["Laser"] = new DescribedProfile();
            Engine.DescribedProfiles["Laser"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Laser"].DisplayName = "Pistolet laserowy";
            Engine.DescribedProfiles["Laser"].Description = "Pistolet laserowy.\n" +
               "Rayguns are a type of fictional directed-energy weapon. They have various alternate names:"
            + "ray gun, death ray, beam gun, blaster, laser gun, phaser, etc. They are a well-known feature "
            + "of science fiction; for such stories they typically have the general function of guns. " 
            + "According to the stories, when activated, a raygun emits a ray, typically visible, " 
            + "usually lethal if it hits a human target, often destructive if it hits mechanical objects"
            + ", with properties and other effects unspecified or varying.";
            Engine.DescribedProfiles["Laser"].DisplayNameOffset = new Vector3(0, 0.2f, 0);
            Engine.DescribedProfiles["Laser"].IsPickable = true;
            Engine.DescribedProfiles["Laser"].Mass = 20;
            Engine.DescribedProfiles["Laser"].MeshName = "LaserGun.mesh";            


            Engine.DescribedProfiles["Axe"] = new DescribedProfile();
            Engine.DescribedProfiles["Axe"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Axe"].DisplayName = "Siekiera";
            Engine.DescribedProfiles["Axe"].Description =
                "Siekiera to najstarsze i nadal używane złożone narzędzie. Od ponad czternastu tysięcy lat jest on używany do kształtowania" +
                "i podziału drewna, rąbania lasów, jako broń obuchowo-sieczna czy też jako symbol heraldyczny";
            Engine.DescribedProfiles["Axe"].DisplayNameOffset = new Vector3(0, 0.2f, 0);
            Engine.DescribedProfiles["Axe"].IsPickable = true;
            Engine.DescribedProfiles["Axe"].Mass = 20;
            Engine.DescribedProfiles["Axe"].MeshName = "Axe.mesh";

            Engine.DescribedProfiles["Tool"] = new DescribedProfile();
            Engine.DescribedProfiles["Tool"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Tool"].DisplayName = "Kombinerki";
            Engine.DescribedProfiles["Tool"].Description =
                "Kombinerki - narzędzie służące do obróbki ręcznej. Składa się z dwóch metalowych części, połączonych w podobny sposób jak nożyczki.";
            Engine.DescribedProfiles["Tool"].DisplayNameOffset = new Vector3(0, 0.2f, 0);
            Engine.DescribedProfiles["Tool"].IsPickable = true;
            Engine.DescribedProfiles["Tool"].Mass = 20;
            Engine.DescribedProfiles["Tool"].MeshName = "Tool.mesh";

            Engine.DescribedProfiles["Menorah"] = new DescribedProfile();
            Engine.DescribedProfiles["Menorah"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Menorah"].DisplayName = "Menora";
            Engine.DescribedProfiles["Menorah"].Description =
                "Menora - jest siedmioramiennym kandelabrem i symbolem Izraela umieszczanym na paszportach, na urzędach państwowych, etc."+
                "Ten ozdobny świecznik był używany przez Żydów w Przybytku i Świątyni Jerozolimskiej. Menora jest jednym z najstarszych "+
                "symboli narodu żydowskiego. Według tradycji symbolizuje on krzew gorejący, który zobaczył Mojżesz na górze Synaj.";
            Engine.DescribedProfiles["Menorah"].DisplayNameOffset = new Vector3(0, 0.2f, 0);
            Engine.DescribedProfiles["Menorah"].IsPickable = true;
            Engine.DescribedProfiles["Menorah"].Mass = 20;
            Engine.DescribedProfiles["Menorah"].MeshName = "Axe.mesh";

            Engine.DescribedProfiles["ArmourBio"] = new DescribedProfile();
            Engine.DescribedProfiles["ArmourBio"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["ArmourBio"].DisplayName = "Kombinezon";
            Engine.DescribedProfiles["ArmourBio"].Description =
                "Wojskowy kombinezon ochronny. Jego wygląd sugeruje, że może chronić on noszącego przed działaniem szkodliwych substancji znajdujacych się w powietrzu.";
            Engine.DescribedProfiles["ArmourBio"].DisplayNameOffset = new Vector3(0, 0.2f, 0);
            Engine.DescribedProfiles["ArmourBio"].IsPickable = true;
            Engine.DescribedProfiles["ArmourBio"].Mass = 20;
            Engine.DescribedProfiles["ArmourBio"].MeshName = "Axe.mesh";

            Engine.DescribedProfiles["RichChair"] = new DescribedProfile();
            Engine.DescribedProfiles["RichChair"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["RichChair"].DisplayName = "Krzesło";
            Engine.DescribedProfiles["RichChair"].DisplayNameOffset = new Vector3(0, 0.3f, 0);
            Engine.DescribedProfiles["RichChair"].Mass = 0;
            Engine.DescribedProfiles["RichChair"].MeshName = "RichChair.mesh";

            Engine.DescribedProfiles["Chair"] = new DescribedProfile();
            Engine.DescribedProfiles["Chair"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Chair"].DisplayName = "Krzesło";
            Engine.DescribedProfiles["Chair"].DisplayNameOffset = new Vector3(0, 0.3f, 0);
            Engine.DescribedProfiles["Chair"].Mass = 0;
            Engine.DescribedProfiles["Chair"].MeshName = "Chair.mesh";

            Engine.DescribedProfiles["Bed"] = new DescribedProfile();
            Engine.DescribedProfiles["Bed"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Bed"].DisplayName = "Łóżko";
            Engine.DescribedProfiles["Bed"].DisplayNameOffset = new Vector3(0, 0.3f, 0);
            Engine.DescribedProfiles["Bed"].Mass = 0;
            Engine.DescribedProfiles["Bed"].MeshName = "Bed.mesh";

            Engine.DescribedProfiles["Toilet"] = new DescribedProfile();
            Engine.DescribedProfiles["Toilet"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Toilet"].DisplayName = "Kibel";
            Engine.DescribedProfiles["Toilet"].DisplayNameOffset = new Vector3(0, 0.7f, 0);
            Engine.DescribedProfiles["Toilet"].Mass = 0;
            Engine.DescribedProfiles["Toilet"].MeshName = "Toilet.mesh";

            Engine.DescribedProfiles["Bath"] = new DescribedProfile();
            Engine.DescribedProfiles["Bath"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Bath"].DisplayName = "Wanna";
            Engine.DescribedProfiles["Bath"].DisplayNameOffset = new Vector3(0, 0.7f, 0);
            Engine.DescribedProfiles["Bath"].Mass = 0;
            Engine.DescribedProfiles["Bath"].MeshName = "Bath.mesh";

            Engine.DescribedProfiles["Table"] = new DescribedProfile();
            Engine.DescribedProfiles["Table"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Table"].DisplayName = "Stół";
            Engine.DescribedProfiles["Table"].DisplayNameOffset = new Vector3(0, 0.7f, 0);
            Engine.DescribedProfiles["Table"].Mass = 0;
            Engine.DescribedProfiles["Table"].MeshName = "Table.mesh";

            Engine.DescribedProfiles["RoundTable"] = new DescribedProfile();
            Engine.DescribedProfiles["RoundTable"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["RoundTable"].DisplayName = "Stół";
            Engine.DescribedProfiles["RoundTable"].DisplayNameOffset = new Vector3(0, 0.7f, 0);
            Engine.DescribedProfiles["RoundTable"].Mass = 0;
            Engine.DescribedProfiles["RoundTable"].MeshName = "RoundTable.mesh";

            Engine.DescribedProfiles["Cupboard"] = new DescribedProfile();
            Engine.DescribedProfiles["Cupboard"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Cupboard"].DisplayName = "Szafka";
            Engine.DescribedProfiles["Cupboard"].DisplayNameOffset = new Vector3(0, 0.7f, 0);
            Engine.DescribedProfiles["Cupboard"].Mass = 0;
            Engine.DescribedProfiles["Cupboard"].MeshName = "Cupboard.mesh";

            Engine.DescribedProfiles["SmallerCupboard"] = new DescribedProfile();
            Engine.DescribedProfiles["SmallerCupboard"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["SmallerCupboard"].DisplayName = "Szafeczka";
            Engine.DescribedProfiles["SmallerCupboard"].DisplayNameOffset = new Vector3(0, 0.7f, 0);
            Engine.DescribedProfiles["SmallerCupboard"].Mass = 0;
            Engine.DescribedProfiles["SmallerCupboard"].MeshName = "SmallerCupboard.mesh";

            Engine.DescribedProfiles["Tap"] = new DescribedProfile();
            Engine.DescribedProfiles["Tap"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Tap"].DisplayName = "Kran";
            Engine.DescribedProfiles["Tap"].DisplayNameOffset = new Vector3(0, 0.7f, 0);
            Engine.DescribedProfiles["Tap"].Mass = 0;
            Engine.DescribedProfiles["Tap"].MeshName = "Tap.mesh";

            Engine.DescribedProfiles["Sink"] = new DescribedProfile();
            Engine.DescribedProfiles["Sink"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Sink"].DisplayName = "Umywalka";
            Engine.DescribedProfiles["Sink"].DisplayNameOffset = new Vector3(0, 0.7f, 0);
            Engine.DescribedProfiles["Sink"].Mass = 0;
            Engine.DescribedProfiles["Sink"].MeshName = "Sink.mesh";

            Engine.DescribedProfiles["Painting1"] = new DescribedProfile();
            Engine.DescribedProfiles["Painting1"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Painting1"].DisplayName = "Obraz";
            Engine.DescribedProfiles["Painting1"].DisplayNameOffset = new Vector3(0, 0.7f, 0);
            Engine.DescribedProfiles["Painting1"].Mass = 0;
            Engine.DescribedProfiles["Painting1"].MeshName = "Painting1.mesh";

            Engine.DescribedProfiles["Painting2"] = new DescribedProfile();
            Engine.DescribedProfiles["Painting2"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Painting2"].DisplayName = "Obraz";
            Engine.DescribedProfiles["Painting2"].DisplayNameOffset = new Vector3(0, 0.7f, 0);
            Engine.DescribedProfiles["Painting2"].Mass = 0;
            Engine.DescribedProfiles["Painting2"].MeshName = "Painting2.mesh";

            Engine.DescribedProfiles["Stove"] = new DescribedProfile();
            Engine.DescribedProfiles["Stove"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.DescribedProfiles["Stove"].DisplayName = "Piec";
            Engine.DescribedProfiles["Stove"].DisplayNameOffset = new Vector3(0, 0.7f, 0);
            Engine.DescribedProfiles["Stove"].Mass = 0;
            Engine.DescribedProfiles["Stove"].MeshName = "Stove.mesh"; 
        }

        static void InitContainerProfiles()
        {
            Engine.ContainerProfiles["Desk"] = new ContainerProfile();
            Engine.ContainerProfiles["Desk"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.ContainerProfiles["Desk"].DisplayName = "Biurko";
            Engine.ContainerProfiles["Desk"].DisplayNameOffset = new Vector3(0, 0.6f, 0);
            Engine.ContainerProfiles["Desk"].Mass = 0;
            Engine.ContainerProfiles["Desk"].MeshName = "Desk.mesh";
            Engine.ContainerProfiles["Desk"].Capacity = 200.0f;

            Engine.ContainerProfiles["Bookcase"] = new ContainerProfile();
            Engine.ContainerProfiles["Bookcase"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.ContainerProfiles["Bookcase"].DisplayName = "Szafka";
            Engine.ContainerProfiles["Bookcase"].DisplayNameOffset = new Vector3(0, 1, 0);
            Engine.ContainerProfiles["Bookcase"].Mass = 0;
            Engine.ContainerProfiles["Bookcase"].MeshName = "BookCase.mesh";
            Engine.ContainerProfiles["Bookcase"].Capacity = 600.0f;

            Engine.ContainerProfiles["Drawers"] = new ContainerProfile();
            Engine.ContainerProfiles["Drawers"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.ContainerProfiles["Drawers"].DisplayName = "Komoda";
            Engine.ContainerProfiles["Drawers"].DisplayNameOffset = new Vector3(0, 1, 0);
            Engine.ContainerProfiles["Drawers"].Mass = 0;
            Engine.ContainerProfiles["Drawers"].MeshName = "Drawers.mesh";
            Engine.ContainerProfiles["Drawers"].Capacity = 600.0f;

            Engine.ContainerProfiles["Vase"] = new ContainerProfile();
            Engine.ContainerProfiles["Vase"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.ContainerProfiles["Vase"].DisplayName = "Waza";
            Engine.ContainerProfiles["Vase"].DisplayNameOffset = new Vector3(0, 1, 0);
            Engine.ContainerProfiles["Vase"].Mass = 0;
            Engine.ContainerProfiles["Vase"].MeshName = "Vase.mesh";
            Engine.ContainerProfiles["Vase"].Capacity = 600.0f;

            Engine.ContainerProfiles["Fridge"] = new ContainerProfile();
            Engine.ContainerProfiles["Fridge"].BodyScaleFactor = Vector3.UNIT_SCALE;
            Engine.ContainerProfiles["Fridge"].DisplayName = "Lodówka";
            Engine.ContainerProfiles["Fridge"].DisplayNameOffset = new Vector3(0, 1, 0);
            Engine.ContainerProfiles["Fridge"].Mass = 0;
            Engine.ContainerProfiles["Fridge"].MeshName = "Fridge.mesh";
            Engine.ContainerProfiles["Fridge"].Capacity = 600.0f;  
        }

        public static void InitCharacterProfiles()
        {
            Engine.CharacterProfiles["Nolty"] = new CharacterProfile();
            Engine.CharacterProfiles["Nolty"].BodyMass = 70;
            Engine.CharacterProfiles["Nolty"].BoundingBoxSize = new Vector3(0.5f, 1.80f, 0.5f);
            Engine.CharacterProfiles["Nolty"].HeadOffset = new Vector3(0, 0.8f, 0);
            Engine.CharacterProfiles["Nolty"].AimOffset = new Vector3(0, 1.05f, 0);
            Engine.CharacterProfiles["Nolty"].DefaultBodyMeshName = "ArmourNolty.mesh";
            Engine.CharacterProfiles["Nolty"].HeadMeshName = "HeadNolty.mesh";
            Engine.CharacterProfiles["Nolty"].ArmsMeshNames[Character.ArmsAppearances.Full] = "Arms0Nolty.mesh";
            Engine.CharacterProfiles["Nolty"].ArmsMeshNames[Character.ArmsAppearances.Half] = "Arms1Nolty.mesh";
            Engine.CharacterProfiles["Nolty"].ArmsMeshNames[Character.ArmsAppearances.Hands] = "Arms2Nolty.mesh";
            Engine.CharacterProfiles["Nolty"].DefaultHeadVisibility = true;
            Engine.CharacterProfiles["Nolty"].DefaultArmsAppearance = Character.ArmsAppearances.Half;
            Engine.CharacterProfiles["Nolty"].DisplayName = "Nolty";
            Engine.CharacterProfiles["Nolty"].DisplayNameOffset = new Vector3(0, 1.35f, 0);
            Engine.CharacterProfiles["Nolty"].WalkSpeed = 1.8f;
            Engine.CharacterProfiles["Nolty"].RunSpeed = 8.0f;
            Engine.CharacterProfiles["Nolty"].Stats = new CharacterStats();
            Engine.CharacterProfiles["Nolty"].Stats.MaxHP = 100;
            Engine.CharacterProfiles["Nolty"].Stats.ResotreHP();
            Engine.CharacterProfiles["Nolty"].SoundFootstepFx = Engine.SoundManager.SoundEffects["footstep_sand.wav"];
            Engine.CharacterProfiles["Nolty"].SoundDieFx = Engine.SoundManager.SoundEffects["die.wav"];

            Engine.CharacterProfiles["Guard"] = new CharacterProfile();
            Engine.CharacterProfiles["Guard"].BodyMass = 70;
            Engine.CharacterProfiles["Guard"].BoundingBoxSize = new Vector3(0.5f, 1.80f, 0.5f);
            Engine.CharacterProfiles["Guard"].HeadOffset = new Vector3(0, 0.8f, 0);
            Engine.CharacterProfiles["Guard"].AimOffset = new Vector3(0, 1.05f, 0);
            Engine.CharacterProfiles["Guard"].DefaultBodyMeshName = "ArmourCloth1.mesh";
            Engine.CharacterProfiles["Guard"].HeadMeshName = "HeadBald1.mesh";
            Engine.CharacterProfiles["Guard"].ArmsMeshNames[Character.ArmsAppearances.Full] = "Arms0Normal.mesh";
            Engine.CharacterProfiles["Guard"].ArmsMeshNames[Character.ArmsAppearances.Half] = "Arms1Normal.mesh";
            Engine.CharacterProfiles["Guard"].ArmsMeshNames[Character.ArmsAppearances.Hands] = "Arms2Normal.mesh";
            Engine.CharacterProfiles["Guard"].DefaultHeadVisibility = true;
            Engine.CharacterProfiles["Guard"].DefaultArmsAppearance = Character.ArmsAppearances.Full;
            Engine.CharacterProfiles["Guard"].DisplayName = "Strażnik";
            Engine.CharacterProfiles["Guard"].DisplayNameOffset = new Vector3(0, 1.35f, 0);
            Engine.CharacterProfiles["Guard"].WalkSpeed = 1.8f;
            Engine.CharacterProfiles["Guard"].RunSpeed = 8.0f;
            Engine.CharacterProfiles["Guard"].Stats = new CharacterStats();
            Engine.CharacterProfiles["Guard"].Stats.MaxHP = 120;
            Engine.CharacterProfiles["Guard"].Stats.ResotreHP();
            Engine.CharacterProfiles["Guard"].SoundFootstepFx = Engine.SoundManager.SoundEffects["footstep_sand.wav"];
            Engine.CharacterProfiles["Guard"].SoundDieFx = Engine.SoundManager.SoundEffects["die.wav"];

            Engine.CharacterProfiles["Sheriff"] = new CharacterProfile();
            Engine.CharacterProfiles["Sheriff"].BodyMass = 70;
            Engine.CharacterProfiles["Sheriff"].BoundingBoxSize = new Vector3(0.5f, 1.80f, 0.5f);
            Engine.CharacterProfiles["Sheriff"].HeadOffset = new Vector3(0, 0.8f, 0);
            Engine.CharacterProfiles["Sheriff"].AimOffset = new Vector3(0, 1.05f, 0);
            Engine.CharacterProfiles["Sheriff"].DefaultBodyMeshName = "ArmourSheriff.mesh";
            Engine.CharacterProfiles["Sheriff"].HeadMeshName = "HeadSheriff.mesh";
            Engine.CharacterProfiles["Sheriff"].ArmsMeshNames[Character.ArmsAppearances.Full] = "Arms0Normal.mesh";
            Engine.CharacterProfiles["Sheriff"].ArmsMeshNames[Character.ArmsAppearances.Half] = "Arms1Normal.mesh";
            Engine.CharacterProfiles["Sheriff"].ArmsMeshNames[Character.ArmsAppearances.Hands] = "Arms2Normal.mesh";
            Engine.CharacterProfiles["Sheriff"].DefaultHeadVisibility = true;
            Engine.CharacterProfiles["Sheriff"].DefaultArmsAppearance = Character.ArmsAppearances.Half;
            Engine.CharacterProfiles["Sheriff"].DisplayName = "Szeryf";
            Engine.CharacterProfiles["Sheriff"] .DisplayNameOffset = new Vector3(0, 1.35f, 0);
            Engine.CharacterProfiles["Sheriff"].WalkSpeed = 1.8f;
            Engine.CharacterProfiles["Sheriff"] .RunSpeed = 8.0f;
            Engine.CharacterProfiles["Sheriff"] .Stats = new CharacterStats();
            Engine.CharacterProfiles["Sheriff"] .Stats.MaxHP = 300;
            Engine.CharacterProfiles["Sheriff"] .Stats.ResotreHP();
            Engine.CharacterProfiles["Sheriff"].SoundFootstepFx = Engine.SoundManager.SoundEffects["footstep_sand.wav"];
            Engine.CharacterProfiles["Sheriff"].SoundDieFx = Engine.SoundManager.SoundEffects["die.wav"];

            Engine.CharacterProfiles["Raider1"] = new CharacterProfile();
            Engine.CharacterProfiles["Raider1"].BodyMass = 70;
            Engine.CharacterProfiles["Raider1"].BoundingBoxSize = new Vector3(0.5f, 1.80f, 0.5f);
            Engine.CharacterProfiles["Raider1"].HeadOffset = new Vector3(0, 0.8f, 0);
            Engine.CharacterProfiles["Raider1"].AimOffset = new Vector3(0, 1.05f, 0);
            Engine.CharacterProfiles["Raider1"].DefaultBodyMeshName = "ArmourCloth1.mesh";
            Engine.CharacterProfiles["Raider1"].HeadMeshName = "HeadBald1.mesh";
            Engine.CharacterProfiles["Raider1"].ArmsMeshNames[Character.ArmsAppearances.Full] = "Arms0Normal.mesh";
            Engine.CharacterProfiles["Raider1"].ArmsMeshNames[Character.ArmsAppearances.Half] = "Arms1Normal.mesh";
            Engine.CharacterProfiles["Raider1"].ArmsMeshNames[Character.ArmsAppearances.Hands] = "Arms2Normal.mesh";
            Engine.CharacterProfiles["Raider1"].DefaultHeadVisibility = true;
            Engine.CharacterProfiles["Raider1"].DefaultArmsAppearance = Character.ArmsAppearances.Full;
            Engine.CharacterProfiles["Raider1"].DisplayName = "Okrutny Zakapior";
            Engine.CharacterProfiles["Raider1"].DisplayNameOffset = new Vector3(0, 1.35f, 0);
            Engine.CharacterProfiles["Raider1"].WalkSpeed = 1.8f;
            Engine.CharacterProfiles["Raider1"].RunSpeed = 8.0f;
            Engine.CharacterProfiles["Raider1"].Stats = new CharacterStats();
            Engine.CharacterProfiles["Raider1"].Stats.MaxHP = 150;
            Engine.CharacterProfiles["Raider1"].Stats.ResotreHP();
            Engine.CharacterProfiles["Raider1"].SoundFootstepFx = Engine.SoundManager.SoundEffects["footstep_sand.wav"];
            Engine.CharacterProfiles["Raider1"].SoundDieFx = Engine.SoundManager.SoundEffects["die.wav"]; 
        }

        public static void InitItemTemplates()
        {
            Engine.ItemTemplates["Cormen"] = new Item();
            Engine.ItemTemplates["Cormen"].Name = "Cormen";
            Engine.ItemTemplates["Cormen"].Weight = 2.0f;
            Engine.ItemTemplates["Cormen"].Profile = Engine.DescribedProfiles["Cormen"];
            Engine.ItemTemplates["Cormen"].Value = 200;
            Engine.ItemTemplates["Cormen"].SpriteMaterial = "Sprites/Cormen";

            Engine.ItemTemplates["Concrete"] = new Item();
            Engine.ItemTemplates["Concrete"].Name = "Concrete";
            Engine.ItemTemplates["Concrete"].Weight = 2.0f;
            Engine.ItemTemplates["Concrete"].Profile = Engine.DescribedProfiles["Concrete"];
            Engine.ItemTemplates["Concrete"].Value = 200;
            Engine.ItemTemplates["Concrete"].SpriteMaterial = "Sprites/Concrete";    

            Engine.ItemTemplates["Colt"] = new ItemPistol();
            Engine.ItemTemplates["Colt"].Name = "Rewolwer Colt";
            Engine.ItemTemplates["Colt"].Weight = 2.0f;
            Engine.ItemTemplates["Colt"].Profile = Engine.DescribedProfiles["Colt"];
            Engine.ItemTemplates["Colt"].Value = 300;
            Engine.ItemTemplates["Colt"].SpriteMaterial = "Sprites/Colt";
            (Engine.ItemTemplates["Colt"] as ItemPistol).RecoilTime = 0.8f;
            (Engine.ItemTemplates["Colt"] as ItemPistol).Damage = 50;
            (Engine.ItemTemplates["Colt"] as ItemPistol).ProjectileMaterial = "ShootTrails/Trail0";            
            (Engine.ItemTemplates["Colt"] as ItemPistol).ProjectileSpeed = 100;
            (Engine.ItemTemplates["Colt"] as ItemPistol).ShootSound = Engine.SoundManager.SoundEffects["gunshot.wav"];

            Engine.ItemTemplates["Laser"] = new ItemPistol();
            Engine.ItemTemplates["Laser"].Name = "Colt Laserowy";
            Engine.ItemTemplates["Laser"].Weight = 2.0f;
            Engine.ItemTemplates["Laser"].Profile = Engine.DescribedProfiles["Laser"];
            Engine.ItemTemplates["Laser"].Value = 300;
            Engine.ItemTemplates["Laser"].SpriteMaterial = "Sprites/LaserGun";
            (Engine.ItemTemplates["Laser"] as ItemPistol).RecoilTime = 0.5f;
            (Engine.ItemTemplates["Laser"] as ItemPistol).Damage = 120;
            (Engine.ItemTemplates["Laser"] as ItemPistol).ProjectileMaterial = "ShootTrails/Trail1";
            (Engine.ItemTemplates["Laser"] as ItemPistol).ProjectileSpeed = 20;
            (Engine.ItemTemplates["Laser"] as ItemPistol).ShootSound = Engine.SoundManager.SoundEffects["blaster.wav"];
            (Engine.ItemTemplates["Laser"] as ItemPistol).HandleOffset = new Vector3(0, 0.1f, -0.05f);

            Engine.ItemTemplates["Axe"] = new ItemM1H();
            Engine.ItemTemplates["Axe"].Name = "Siekiera";
            Engine.ItemTemplates["Axe"].Weight = 2.0f;
            Engine.ItemTemplates["Axe"].Profile = Engine.DescribedProfiles["Axe"];
            Engine.ItemTemplates["Axe"].Value = 20;
            Engine.ItemTemplates["Axe"].SpriteMaterial = "Sprites/Axe";
            (Engine.ItemTemplates["Axe"] as ItemM1H).HandleOffset = new Vector3(0.05f, 0, -0.2f);
            (Engine.ItemTemplates["Axe"] as ItemM1H).Damage = 40;

            Engine.ItemTemplates["Menorah"] = new Item();
            Engine.ItemTemplates["Menorah"].Name = "Menorah";
            Engine.ItemTemplates["Menorah"].Weight = 2.0f;
            Engine.ItemTemplates["Menorah"].Profile = Engine.DescribedProfiles["Menorah"];
            Engine.ItemTemplates["Menorah"].Value = 2000;
            Engine.ItemTemplates["Menorah"].SpriteMaterial = "Sprites/Menorah";

            Engine.ItemTemplates["Tool"] = new Item();
            Engine.ItemTemplates["Tool"].Name = "Kombinerki";
            Engine.ItemTemplates["Tool"].Weight = 2.0f;
            Engine.ItemTemplates["Tool"].Profile = Engine.DescribedProfiles["Tool"];
            Engine.ItemTemplates["Tool"].Value = 20;
            Engine.ItemTemplates["Tool"].SpriteMaterial = "Sprites/Tool";

            Engine.ItemTemplates["ArmourBio"] = new ItemArmour();
            Engine.ItemTemplates["ArmourBio"].Name = "Kombinezon";
            Engine.ItemTemplates["ArmourBio"].Weight = 2.0f;
            Engine.ItemTemplates["ArmourBio"].Profile = Engine.DescribedProfiles["ArmourBio"];
            Engine.ItemTemplates["ArmourBio"].Value = 100;
            Engine.ItemTemplates["ArmourBio"].SpriteMaterial = "Sprites/ArmourBio";
            (Engine.ItemTemplates["ArmourBio"] as ItemArmour).HeadVisibility = false;
            (Engine.ItemTemplates["ArmourBio"] as ItemArmour).BodyMeshName = "ArmourBio.mesh";
            (Engine.ItemTemplates["ArmourBio"] as ItemArmour).ArmsAppearance = Character.ArmsAppearances.None;

            Engine.ItemTemplates["ArmourRaider"] = new ItemArmour();
            Engine.ItemTemplates["ArmourRaider"].Name = "Kostium";
            Engine.ItemTemplates["ArmourRaider"].Weight = 2.0f;
            Engine.ItemTemplates["ArmourRaider"].Profile = Engine.DescribedProfiles["ArmourBio"];
            Engine.ItemTemplates["ArmourRaider"].Value = 20;
            Engine.ItemTemplates["ArmourRaider"].SpriteMaterial = "Sprites/Axe";
            (Engine.ItemTemplates["ArmourRaider"] as ItemArmour).HeadVisibility = true;
            (Engine.ItemTemplates["ArmourRaider"] as ItemArmour).BodyMeshName = "ArmourRaider.mesh";
            (Engine.ItemTemplates["ArmourRaider"] as ItemArmour).ArmsAppearance = Character.ArmsAppearances.Full;

            Engine.ItemTemplates["ArmourCloth1"] = new ItemArmour();
            Engine.ItemTemplates["ArmourCloth1"].Name = "Kostium";
            Engine.ItemTemplates["ArmourCloth1"].Weight = 2.0f;
            Engine.ItemTemplates["ArmourCloth1"].Profile = Engine.DescribedProfiles["Axe"];
            Engine.ItemTemplates["ArmourCloth1"].Value = 20;
            Engine.ItemTemplates["ArmourCloth1"].SpriteMaterial = "Sprites/Axe";
            (Engine.ItemTemplates["ArmourCloth1"] as ItemArmour).HeadVisibility = true;
            (Engine.ItemTemplates["ArmourCloth1"] as ItemArmour).BodyMeshName = "ArmourCloth1.mesh";
            (Engine.ItemTemplates["ArmourCloth1"] as ItemArmour).ArmsAppearance = Character.ArmsAppearances.Full;

            Engine.ItemTemplates["ArmourCloth2"] = new ItemArmour();
            Engine.ItemTemplates["ArmourCloth2"].Name = "Kostium";
            Engine.ItemTemplates["ArmourCloth2"].Weight = 2.0f;
            Engine.ItemTemplates["ArmourCloth2"].Profile = Engine.DescribedProfiles["Axe"];
            Engine.ItemTemplates["ArmourCloth2"].Value = 20;
            Engine.ItemTemplates["ArmourCloth2"].SpriteMaterial = "Sprites/Axe";
            (Engine.ItemTemplates["ArmourCloth2"] as ItemArmour).HeadVisibility = true;
            (Engine.ItemTemplates["ArmourCloth2"] as ItemArmour).BodyMeshName = "ArmourCloth2.mesh";
            (Engine.ItemTemplates["ArmourCloth2"] as ItemArmour).ArmsAppearance = Character.ArmsAppearances.Half;

            Engine.ItemTemplates["ArmourSheriff"] = new ItemArmour();
            Engine.ItemTemplates["ArmourSheriff"].Name = "Kostium";
            Engine.ItemTemplates["ArmourSheriff"].Weight = 2.0f;
            Engine.ItemTemplates["ArmourSheriff"].Profile = Engine.DescribedProfiles["Axe"];
            Engine.ItemTemplates["ArmourSheriff"].Value = 20;
            Engine.ItemTemplates["ArmourSheriff"].SpriteMaterial = "Sprites/Axe";
            (Engine.ItemTemplates["ArmourSheriff"] as ItemArmour).HeadVisibility = true;
            (Engine.ItemTemplates["ArmourSheriff"] as ItemArmour).BodyMeshName = "ArmourSheriff.mesh";
            (Engine.ItemTemplates["ArmourSheriff"] as ItemArmour).ArmsAppearance = Character.ArmsAppearances.Half;

            Engine.ItemTemplates["ArmourNolty"] = new ItemArmour();
            Engine.ItemTemplates["ArmourNolty"].Name = "Kostium";
            Engine.ItemTemplates["ArmourNolty"].Weight = 2.0f;
            Engine.ItemTemplates["ArmourNolty"].Profile = Engine.DescribedProfiles["Axe"];
            Engine.ItemTemplates["ArmourNolty"].Value = 20;
            Engine.ItemTemplates["ArmourNolty"].SpriteMaterial = "Sprites/Axe";
            (Engine.ItemTemplates["ArmourNolty"] as ItemArmour).HeadVisibility = true;
            (Engine.ItemTemplates["ArmourNolty"] as ItemArmour).BodyMeshName = "ArmourNolty.mesh";
            (Engine.ItemTemplates["ArmourNolty"] as ItemArmour).ArmsAppearance = Character.ArmsAppearances.Half;
        }


        static void Main(string[] args)
        {
            Dialogues.Initialise();
            Engine.Initialise();
            
            Engine.CurrentLevel = new Level();
            Engine.CurrentLevel.SetGraphicsMesh("World.mesh");
            Engine.CurrentLevel.SetPlantsMesh("Plants.mesh");
            Engine.CurrentLevel.SetCollisionMesh("WorldCol.mesh");
            Engine.CurrentLevel.SetNavmesh("navmesh.nvm");
            Engine.CurrentLevel.SetClimbingEdges("testmap.edg");

            Engine.FlagOn("Bob/Zaczepka");
            Engine.FlagOn("Sherif/FirstDialogue");
            Engine.FlagOn("Kyle/FirstDialogue");

            Engine.SoundManager.CreateSoundEffect("footstep_sand.wav");           
            Engine.SoundManager.CreateSoundEffect("gunshot.wav");
            Engine.SoundManager.CreateSoundEffect("blaster.wav");
            Engine.SoundManager.CreateSoundEffect("m1hswing.wav");
            Engine.SoundManager.CreateSoundEffect("die.wav");
            Engine.SoundManager.CreateSoundEffect("meathit1.wav");
            Engine.SoundManager.CreateSoundEffect("meathit2.wav");
            Engine.SoundManager.CreateSoundEffect("meathit3.wav");
            Engine.SoundManager.CreateSoundEffect("argh1.wav");
            Engine.SoundManager.CreateSoundEffect("argh2.wav");
            Engine.SoundManager.CreateSoundEffect("argh3.wav");
            Engine.SoundManager.CreateSoundEffect("argh4.wav");
            Engine.SoundManager.CreateSoundEffect("argh5.wav");
            Engine.SoundManager.CreateSoundEffect("argh6.wav");
            Engine.SoundManager.CreateSoundEffect("ricochet.wav");
            Engine.SoundManager.CreateSoundEffect("explosion.wav", false);
            Engine.SoundManager.CreateMusic("nofight.ogg");
            Engine.SoundManager.CreateMusic("fight.ogg");

            Engine.SoundManager.LoadAllSounds();                            
            Engine.SoundManager.SoundEffects["footstep_sand.wav"].SetMinMaxDistance(2, 50);
            Engine.SoundManager.SoundEffects["gunshot.wav"].SetMinMaxDistance(2, 50);
            Engine.SoundManager.SoundEffects["blaster.wav"].SetMinMaxDistance(2, 50);
            Engine.SoundManager.SoundEffects["m1hswing.wav"].SetMinMaxDistance(2, 50);
            Engine.SoundManager.SoundEffects["die.wav"].SetMinMaxDistance(2, 50);
            Engine.SoundManager.SoundEffects["meathit1.wav"].SetMinMaxDistance(2, 50);
            Engine.SoundManager.SoundEffects["meathit2.wav"].SetMinMaxDistance(2, 50);
            Engine.SoundManager.SoundEffects["meathit3.wav"].SetMinMaxDistance(2, 50);
            Engine.SoundManager.SoundEffects["argh1.wav"].SetMinMaxDistance(2, 50);
            Engine.SoundManager.SoundEffects["argh2.wav"].SetMinMaxDistance(2, 50);
            Engine.SoundManager.SoundEffects["argh3.wav"].SetMinMaxDistance(2, 50);
            Engine.SoundManager.SoundEffects["argh4.wav"].SetMinMaxDistance(2, 50);
            Engine.SoundManager.SoundEffects["argh5.wav"].SetMinMaxDistance(2, 50);
            Engine.SoundManager.SoundEffects["argh6.wav"].SetMinMaxDistance(2, 50);
            Engine.SoundManager.SoundEffects["ricochet.wav"].SetMinMaxDistance(2, 50);
            Engine.SoundManager.Musics["nofight.ogg"].Play();
            Engine.SoundManager.Musics["nofight.ogg"].FmodChannel.setVolume(0.2f);


            InitDescribedProfiles();
            InitContainerProfiles();            
            InitItemTemplates();
            InitCharacterProfiles();
                                                 

            HingedDoorProfile doorProfile = new HingedDoorProfile();
            doorProfile.MaxAngle = new Degree(90);
            doorProfile.Speed = 0.025f;
            doorProfile.BodyScaleFactor = Vector3.UNIT_SCALE;
            doorProfile.Description = "";
            doorProfile.MeshName = "Door.mesh";            
            /* 
            HingedDoor door = new HingedDoor(doorProfile);
            door.Position = new Vector3(2.1f, 1.72f, -5.55f);
            door.Orientation = Helper.QuaternionFromAngle(new Degree(90), Vector3.UNIT_Y);
            door.Direction = HingedDoor.DoorDirection.Outward;
            Engine.ObjectManager.Add(door); */

            Character player = Engine.ObjectManager.NewCharacter(Engine.CharacterProfiles["Nolty"], "Nolty");            
            player.Position = new Vector3(0, 2, 0);
            player.TurnTo(new Vector3(0, 1, -2));
            player.Profile.DisplayName = "Nolty";
            player.Equipment.Capacity = 100.0f;
            player.InterpolateTurning = false;
            player.OnPickedItem += ((me, item) =>
                {
                    if (item.Name == "Menorah")
                        Engine.HUDController.PostScreenMessage("Powinienem to komuś pokazać...");
                });
                                 
            Engine.GameCamera.Distance = 3;                        

            Light light = Engine.SceneManager.CreateLight();
            light.Type = Light.LightTypes.LT_DIRECTIONAL;
            light.Direction = new Vector3(0.68f, -0.59f, -0.41f).NormalisedCopy;
            light.DiffuseColour = new ColourValue(1, 1, 1);                        

            Engine.SceneManager.AmbientLight = new ColourValue(0.4f, 0.35f, 0.25f);
            //Engine.SceneManager.AmbientLight = new ColourValue(0,0,0);
            Engine.Viewport.BackgroundColour = new ColourValue(0.2f, 0.4f, 0.6f);

            Engine.SceneManager.SetSkyBox(true, "SkyBox/Default", 10, true);
            Engine.SceneManager.ShadowTechnique = ShadowTechnique.SHADOWTYPE_TEXTURE_ADDITIVE_INTEGRATED;
            Engine.SceneManager.SetShadowTextureSettings(512, 3);
            Engine.SceneManager.SetShadowTextureCountPerLightType(Light.LightTypes.LT_DIRECTIONAL, 3);
            Engine.SceneManager.ShadowDirectionalLightExtrusionDistance = 160;
            Engine.SceneManager.ShadowFarDistance = 160;            
            PSSMShadowCameraSetup pssmCamSetup = new PSSMShadowCameraSetup();  
            pssmCamSetup.CalculateSplitPoints(3, 0.5f, Engine.SceneManager.ShadowFarDistance);
          
            pssmCamSetup.SplitPadding = 0.5f;
            PSSMShadowCameraSetup.Const_SplitPointList splitPoints = pssmCamSetup.GetSplitPoints();            
            Engine.SceneManager.SetShadowCameraSetup(new ShadowCameraSetupPtr(pssmCamSetup));
            IEnumerator<float> pointsEnu = splitPoints.GetEnumerator();
            Vector4 splitPointsVect = new Vector4();
            int di = 0;
            while (pointsEnu.MoveNext())
            {
                splitPointsVect[di] = pointsEnu.Current;                
                di++;                
            }
            var sharedGpuParams = GpuProgramManager.Singleton.GetSharedParameters("SharedParams/DirLight");
            sharedGpuParams.SetNamedConstant("pssmSplitPoints", splitPointsVect);            
                                                  
            Engine.SceneManager.SetShadowTextureCasterMaterial("shadowCasterMaterial");
            Engine.SceneManager.ShadowCasterRenderBackFaces = false;
            Engine.SceneManager.SetShadowTextureFadeStart(1.0f);
            Engine.SceneManager.SetShadowTextureFadeEnd(1.0f);
            Engine.SceneManager.SetShadowTexturePixelFormat(PixelFormat.PF_FLOAT32_RGB);

            CompositorManager.Singleton.AddCompositor(Engine.Viewport, "Supersampling");
            CompositorManager.Singleton.AddCompositor(Engine.Viewport, "Bloom");
            CompositorManager.Singleton.AddCompositor(Engine.Viewport, "Enhance");
            CompositorManager.Singleton.SetCompositorEnabled(Engine.Viewport, "Supersampling", true);
            CompositorManager.Singleton.SetCompositorEnabled(Engine.Viewport, "Bloom", true);
            CompositorManager.Singleton.SetCompositorEnabled(Engine.Viewport, "Enhance", true);            
            
            Engine.SceneManager.SetFog(FogMode.FOG_EXP2, new ColourValue(0.6f, 0.4f, 0.2f, 1f), 0.02f, 5, 50);
            
            Engine.HumanController.AttachCharacter(player);
                       
            Engine.GuiManager.Pointer.Width = 0.03f * Engine.GuiManager.Proportions;
            Engine.GuiManager.Pointer.Height = 0.04f;
            Engine.GuiManager.Pointer.MaterialName = "Overlay/Pointer";

            Mogre.MaterialManager.Singleton.DefaultAnisotropy = 8; 

            MainScript.CreateGuards();
            MainScript.CreateSheriff();
            MainScript.CreateScenery();
            MainScript.CreateBobArea();
            bool enhance = true;

            Engine.CustomCallback += (() =>
            {
                if (Engine.IsKeyTyped(MOIS.KeyCode.KC_F1))
                    Engine.ExitProgram = true;

                
                if (Engine.IsKeyTyped(MOIS.KeyCode.KC_U))                                    
                    Console.WriteLine(player.Position.ToString());                

                 if (Engine.IsKeyTyped(MOIS.KeyCode.KC_B))
                {
                    MainScript.SpawnRaider(
                        new Vector3(Mogre.Math.RangeRandom(-2, 2), 3, Mogre.Math.RangeRandom(-2, 2)) + new Vector3(-3.287277f, 0.7301673f, 43.94728f),
                        "Raider",
                        false);
                }

                if (Engine.IsKeyTyped(MOIS.KeyCode.KC_N))
                {
                    MainScript.SpawnRaider(
                        new Vector3(Mogre.Math.RangeRandom(-2, 2), 3, Mogre.Math.RangeRandom(-2, 2)) + new Vector3(-0.287277f, 0.7301673f, -20.94728f),
                        "Raider2",
                        false);
                } 

                if (Engine.IsKeyTyped(MOIS.KeyCode.KC_F2))
                {
                    enhance = !enhance;
                    CompositorManager.Singleton.SetCompositorEnabled(Engine.Viewport, "Supersampling", enhance);                                                    
                }

              /*  if (Engine.IsKeyTyped(MOIS.KeyCode.KC_H))
                {
                    player.Armour = Engine.ItemTemplates["ArmourBio"].Clone() as ItemArmour;
                } 

                if (Engine.IsKeyTyped(MOIS.KeyCode.KC_P))
                {
                    Character sheriff = Engine.ObjectManager.GetCharacter("Sheriff");
                    sheriff.PushTask(new CharTaskMoveTo(sheriff, player.Position, true));
                } */
            });

 
            while (!Engine.ExitProgram)
            {  
                Engine.Update();
                
                if (Engine.Keyboard.IsKeyDown(MOIS.KeyCode.KC_F3))
                    Engine.NewtonDebugger.ShowDebugInformation();
                else
                    Engine.NewtonDebugger.HideDebugInformation();
                                                                 
                //System.Threading.Thread.Sleep(30);
            }

            Mogre.MaterialManager.Singleton.UnloadAll();
            Engine.Root.Dispose();
            Engine.SoundManager.UnloadAllSounds();
            Engine.SoundManager.FmodSystem.release();            
        }                
    }
}
